/*    */ package com.zimbra.cs.account.ldap.upgrade;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.account.ldap.LdapDIT;
/*    */ import com.zimbra.cs.account.ldap.LdapProv;
/*    */ import com.zimbra.cs.ldap.IAttributes;
/*    */ import com.zimbra.cs.ldap.LdapClient;
/*    */ import com.zimbra.cs.ldap.LdapServerType;
/*    */ import com.zimbra.cs.ldap.LdapUsage;
/*    */ import com.zimbra.cs.ldap.SearchLdapOptions.SearchLdapVisitor;
/*    */ import com.zimbra.cs.ldap.ZAttributes;
/*    */ import com.zimbra.cs.ldap.ZLdapContext;
/*    */ import com.zimbra.cs.ldap.ZLdapFilter;
/*    */ import com.zimbra.cs.ldap.ZLdapFilterFactory;
/*    */ import com.zimbra.cs.ldap.ZMutableEntry;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class BUG_50458
/*    */   extends UpgradeOp
/*    */ {
/*    */   private static final String VALUE_TO_REMOVE = "syncListener";
/*    */   
/*    */   void doUpgrade()
/*    */     throws ServiceException
/*    */   {
/* 37 */     ZLdapContext zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UPGRADE);
/*    */     try {
/* 39 */       doDomain(zlc);
/*    */     } finally {
/* 41 */       LdapClient.closeContext(zlc);
/*    */     }
/*    */   }
/*    */   
/*    */   private void doDomain(ZLdapContext modZlc)
/*    */   {
/* 47 */     String[] bases = this.prov.getDIT().getSearchBases(16);
/* 48 */     String query = "(&" + ZLdapFilterFactory.getInstance().allDomains().toFilterString() + "(" + "zimbraPasswordChangeListener" + "=" + "syncListener" + ")" + ")";
/*    */     
/*    */ 
/* 51 */     upgrade(modZlc, bases, query);
/*    */   }
/*    */   
/*    */   private void upgrade(ZLdapContext modZlc, String[] bases, String query)
/*    */   {
/* 56 */     SearchLdapOptions.SearchLdapVisitor visitor = new Bug50458Visitor(this, modZlc);
/*    */     
/* 58 */     String[] attrs = { "zimbraPasswordChangeListener" };
/*    */     
/* 60 */     for (String base : bases) {
/*    */       try {
/* 62 */         this.prov.searchLdapOnMaster(base, query, attrs, visitor);
/*    */       }
/*    */       catch (ServiceException e) {
/* 65 */         this.printer.println("Caught ServiceException while searching " + query + " under base " + base);
/* 66 */         this.printer.printStackTrace(e);
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   private static class Bug50458Visitor extends SearchLdapOptions.SearchLdapVisitor {
/*    */     private UpgradeOp upgradeOp;
/*    */     private ZLdapContext modZlc;
/*    */     
/*    */     Bug50458Visitor(UpgradeOp upgradeOp, ZLdapContext modZlc) {
/* 76 */       super();
/* 77 */       this.upgradeOp = upgradeOp;
/* 78 */       this.modZlc = modZlc;
/*    */     }
/*    */     
/*    */     public void visit(String dn, IAttributes ldapAttrs)
/*    */     {
/*    */       try {
/* 84 */         doVisit(dn, (ZAttributes)ldapAttrs);
/*    */       } catch (ServiceException e) {
/* 86 */         this.upgradeOp.printer.println("entry skipped, encountered error while processing entry at:" + dn);
/* 87 */         this.upgradeOp.printer.printStackTrace(e);
/*    */       }
/*    */     }
/*    */     
/*    */     public void doVisit(String dn, ZAttributes ldapAttrs) throws ServiceException {
/* 92 */       ZMutableEntry entry = LdapClient.createMutableEntry();
/* 93 */       entry.setAttr("zimbraPasswordChangeListener", "");
/* 94 */       this.upgradeOp.replaceAttrs(this.modZlc, dn, entry);
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/upgrade/BUG_50458.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */